<template>
    <BPTable ref='tableRef' align='center' row-key='id' :columns='columns' :api='pageApi' :buttons='buttons'>
        <!-- <template #$action="{record}">
            <BTextButton type="primary" @click="openRecharge(record)">充值</BTextButton>
        </template> -->


        <template #isOnline="{record}">
            <a-tag color="success" v-if="record.isOnline">是</a-tag>
            <a-tag color="error" v-else>否</a-tag>
        </template>
        <template #enable="{record}">
            <a-tag color="success" v-if="record.enable">已启用</a-tag>
            <a-tag color="error" v-else>已封禁</a-tag>
        </template>

         <!-- <template #$action="{record}">
            <template v-if="record.official">
                <BTextButton type="primary" @click="update(record)">修改</BTextButton>
                <BTextButton type="error" @click="del(record)">删除</BTextButton>
            </template>
        </template> -->
    </BPTable>

    
</template>

<script lang='ts' setup>
    import { ref } from "vue";
    import { pageApi, deleteApi, forbidApi, enableApi } from '@/api/User'
    import { parseTime } from "@/utils";

import { message, Modal } from "ant-design-vue";
import { useI18nStore } from "@/store/i18n";
import { optionsApi } from "@/api/UserGroup";


    const columns = ref<Column[]>([
        {
            dataIndex : 'account',
            title : '账号',
            inSearch : true,
        },

        {
            dataIndex : 'groupId',
            title : '分组',
            inSearch : true,
            customRender({record}) {
                return record.group ? record.group.name : ''
            },
            type: 'select',
            labelField: 'name',
            valueField: 'id',
            options: () => optionsApi()
        },

        {
            dataIndex : 'expireAt',
            title : '有效期',
            //inSearch : true,
            customRender({record}) {
                return parseTime(record.expireAt)
            }
        },

        {
            dataIndex : 'directParent',
            title : '推荐人',
            //inSearch : true,
            customRender({record}) {
                return record.parent ? record.parent.account : ''
            }
        },

        {
            dataIndex : 'balance',
            title : '余额',
        },

        {
            dataIndex : 'commissionAmount',
            title : '佣金',
        },

        

        // {
        //     dataIndex : 'enable',
        //     title : '是否启用',
        //     inSearch : true,
        //     type: 'select',
        //     options: [{label: '启用', value: true}, {label: '禁用', value: true}]
        // },


        {
            title : '注册时间',
            dataIndex : 'registerTime',
            align : 'center',
            customRender({text}) {
                return parseTime(text)
            }
        },

       
    ])


    


    


    

    
</script>